package com.gcstorage.tvdev.net;

import com.google.gson.JsonElement;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.HeaderMap;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.PartMap;
import retrofit2.http.QueryMap;
import retrofit2.http.Streaming;
import retrofit2.http.Url;

/**
 * Created by Xu on 2019-10-22 17:53
 */
public interface HttpApi {

    @GET
    Observable<JsonElement> get(@Url String url, @QueryMap Map<String, Object> parameter);

    @GET
    Observable<JsonElement> get(@Url String url, @QueryMap Map<String, Object> parameter, @HeaderMap Map<String, Object> headers);

    @Multipart
    @POST
    Observable<JsonElement> post(@Url String url, @PartMap HashMap<String, Object> request);

    @Multipart
    @POST
    Observable<JsonElement> post(@Url String url, @PartMap HashMap<String, Object> request, @HeaderMap Map<String, Object> headers);

    @FormUrlEncoded
    @POST
    Observable<JsonElement> post(@Url String url, @FieldMap Map<String, Object> parameter);

    @FormUrlEncoded
    @POST
    Observable<JsonElement> post(@Url String url, @FieldMap Map<String, Object> parameter, @HeaderMap Map<String, Object> headers);

    @POST
    Observable<JsonElement> post(@Url String url, @Body RequestBody requestBody);

    @POST
    Observable<JsonElement> post(@Url String url, @Body RequestBody requestBody, @HeaderMap Map<String, Object> headers);

    @POST
    @Multipart
    Observable<JsonElement> upload(@Url String url, @QueryMap Map<String, Object> map, @Part List<MultipartBody.Part> parts);

    @POST
    @Multipart
    Observable<JsonElement> upload(@Url String url, @QueryMap Map<String, Object> map, @Part List<MultipartBody.Part> parts, @HeaderMap Map<String, Object> headers);

    @GET
    @Streaming
    Observable<ResponseBody> downLoadFile(@Url String url);

    @Streaming
    @GET
    Call<ResponseBody> download(@Url String url);
}
